/*
 * marketsim-eclipsetrader
 *
 * Copyright (C) 2008-2011 Steve Phelps and John Cartlidge
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 */
package victria.marketsim.core;

import java.util.List;

public interface MarketService {

	/**
	 * Place an order in the market.
	 * 
	 * @param   the order to place.
	 * @return  The id of the order.
	 */
	public long placeOrder(Order order);
	
	/**
	 * @param id
	 * @param order
	 * @return  The new order id
	 */
	public long replaceOrder(long id, Order order);
	
	public boolean cancelOrder(long id);
	
	public boolean cancelOrders(Object trader);
	
	/**
	 * Return the bids in the order book (visible bids).
	 * @return
	 */
	public List<Order> getVisibleBids();
	
	/**
	 * Return the asks in the order book (visible asks).
	 * @return
	 */
	public List<Order> getVisibleAsks();
	
	/**
	 * Fetch all the outstanding bids in the market.
	 * @return
	 */
	public List<Order> getBids();
	
	/**
	 * Fetch all the outstanding asks in the market.
	 * @return
	 */
	public List<Order> getAsks();
	
	/**
	 * Fetch all the outstanding orders for the given trader.
	 * @param trader
	 * @return
	 */
	public List<Order> getOrders(Object trader);
	
	public Order getOrder(long id);
	
	public boolean isOutstanding(long id);	
	
	public void registerTrader(Object trader);
	public Object allocateUniqueTrader();
	
	public MarketState getMarketState();
	
	public boolean isRunning();
	
	public void openMarket();
	
	public long currentTimeMillis();

	public double getLastTransactionPrice();
}